function showAddr(inputTextName,hiddenInputValue,selectType,adminScope){
	var url = context+"/common/address/address_select_main.jsp?type="+selectType.split(";")[0];
	if(adminScope=="1"){
		url = url + "&adminScope=1";
	}	
	var textNames = document.getElementsByName(inputTextName)[0].value;
	var inputValues = document.getElementsByName(hiddenInputValue)[0].value;
	var obj = new Object();
	obj.textNames = textNames;
	obj.inputValues = inputValues;
	obj.selectType = selectType;
	var value = window.showModalDialog(url,obj,"dialogHeight:550px;dialogWidth:720px;status=off");
	if(value==""||value==undefined) {
	    return "";
	}
    if(value=="empty") {
		document.getElementsByName(inputTextName)[0].value = "";
	    document.getElementsByName(hiddenInputValue)[0].value = "";
	    return "";
	}
	var valueArray = value.split(";");
	var newText = "";
	for(var i = 0; i < valueArray.length; i++){
		var groupSplit = valueArray[i].split(",");
			if(groupSplit[1] ==undefined) continue;
		if(newText==""){
			newText = groupSplit[1];
		}else{
			newText =  newText+","+groupSplit[1];
		}
	}
	document.getElementsByName(inputTextName)[0].value = newText;
	document.getElementsByName(hiddenInputValue)[0].value = value;
}

function showAddrAndScript(inputTextName,hiddenInputValue,selectType,evalscript){
	var returnValue = showAddr(inputTextName,hiddenInputValue,selectType);
	if(evalscript!=""){
		if(returnValue!=""){
			var script = evalscript+'()';
			eval(script);
		}
	}
}

function showAddrAndScriptWithParas(inputTextName,hiddenInputValue,selectType,evalscript){
	var returnValue = showAddr(inputTextName,hiddenInputValue,selectType);
	if(evalscript!=""){
		if(returnValue!=""){
			eval(evalscript);
		}
	}
}

function showRole(inputTextName,hiddenInputValue,selectType){
	var url = context+"/common/selectRole/role_select_main.jsp";
	var textNames = document.getElementsByName(inputTextName)[0].value;
	var inputValues = document.getElementsByName(hiddenInputValue)[0].value;
	var obj = new Object();
	obj.textNames = textNames;
	obj.inputValues = inputValues;
	obj.selectType = selectType;
	var value = window.showModalDialog(url,obj,"dialogHeight:400px;dialogWidth:400px;status=off");
	if(value==""||value==undefined) {
	    return "";
	}
    if(value=="empty") {
		document.getElementsByName(inputTextName)[0].value = "";
	    document.getElementsByName(hiddenInputValue)[0].value = "";
	    return "";
	}
	var valueArray = value.split(";");
	var newText = "";
	for(var i = 0; i < valueArray.length; i++){
		var groupSplit = valueArray[i].split(",");
		if(newText==""){
			newText = groupSplit[0];
		}else{
			newText =  newText+","+groupSplit[0];
		}
	}
	
	document.getElementsByName(inputTextName)[0].value = newText;
	document.getElementsByName(hiddenInputValue)[0].value = value;
}

function showTargetAndScript(inputTextName,hiddenInputValue,selectType,showTargets,evalscript){
	var returnValue = showTarget(inputTextName,hiddenInputValue,selectType,showTargets);
	if(evalscript!=""){
		if(returnValue!=""){
			var script = evalscript+'()';
			eval(script);
		}
	}
}

function showTargetAndScriptWithParam(inputTextName,hiddenInputValue,selectType,showTargets,evalscript,param,aid){
	var returnValue = showTarget(inputTextName,hiddenInputValue,selectType,showTargets,param,aid);	
	if(evalscript!=""){
		if(returnValue!=""){
			var script = evalscript+"('"+param+"')";
			eval(script);
		}
	}
}

function showTarget(inputTextName,hiddenInputValue,selectType,showTargets,param,aid){
	var url = context+"/target/dlg/target_select_main.jsp?aid="+aid;
	var textNames = document.getElementsByName(inputTextName)[0].value;
	var inputValues = document.getElementsByName(hiddenInputValue)[0].value;
	var obj = new Object();
	obj.textNames = textNames;
	obj.inputValues = inputValues;
	obj.selectType = selectType;
	if(showTargets==false){
	obj.showTarget = showTargets;
	}else{
	obj.showTarget = "true";
	}
	var value = window.showModalDialog(url,obj,"dialogHeight:500px;dialogWidth:720px;status=off");
	if(value==""||value==undefined) {
	    return "";
	}
    if(value=="empty") {
		document.getElementsByName(inputTextName)[0].value = "";
	    document.getElementsByName(hiddenInputValue)[0].value = "";
	    return "";
	}
	var valueArray = value.split(";");
	var newText = "";
	for(var i = 0; i < valueArray.length; i++){
		var groupSplit = valueArray[i].split(",");
			if(groupSplit[1] ==undefined) cotinue;
		if(newText==""){
			newText = groupSplit[1];
		}else{
			newText =  newText+","+groupSplit[1];
		}
	}
	document.getElementsByName(inputTextName)[0].value = newText;
	document.getElementsByName(hiddenInputValue)[0].value = value;
}


function showDailyTarget(inputTextName,hiddenInputValue,selectType,showTargets,evalscript,aid){
	var url = context+"/target/dlg/target_select_main.jsp?flg_daily=1&aid="+aid;
	var textNames = document.getElementsByName(inputTextName)[0].value;
	var inputValues = document.getElementsByName(hiddenInputValue)[0].value;
	var obj = new Object();
	obj.textNames = textNames;
	obj.inputValues = inputValues;
	obj.selectType = selectType;
	if(showTargets==false){
	obj.showTarget = showTargets;
	}else{
	obj.showTarget = "true";
	}
	var value = window.showModalDialog(url,obj,"dialogHeight:500px;dialogWidth:720px;status=off");
	if(value==""||value==undefined) {
	   
	    if(evalscript!=""){
	      var script = evalscript+'()';
		  eval(script);
	      return "";
	    }
	    else
	    {
	      return "";
	    }
	}
    if(value=="empty") {
		document.getElementsByName(inputTextName)[0].value = "";
	    document.getElementsByName(hiddenInputValue)[0].value = "";
	    if(evalscript!=""){
	      var script = evalscript+'()';
		  eval(script);
	      return "";
	    }
	    else
	    {
	      return "";
	    }
	    
	}
	var valueArray = value.split(";");
	var newText = "";
	for(var i = 0; i < valueArray.length; i++){
		var groupSplit = valueArray[i].split(",");
			if(groupSplit[1] ==undefined) cotinue;
		if(newText==""){
			newText = groupSplit[1];
		}else{
			newText =  newText+","+groupSplit[1];
		}
	}
	document.getElementsByName(inputTextName)[0].value = newText;
	document.getElementsByName(hiddenInputValue)[0].value = value;
	
	//alert("evalscript::"+evalscript);
	if(evalscript!=""){
	    var script = evalscript+'()';
		eval(script);
	}
}

function showDailyTargetByType(inputTextName,hiddenInputValue,selectType,showTargets,evalscript,aid){
	var url = context+"/target/dtAdd/dailyTarget_select_main.jsp?flg_daily=1&aid="+aid;
	var textNames = document.getElementsByName(inputTextName)[0].value;
	var inputValues = document.getElementsByName(hiddenInputValue)[0].value;
	var obj = new Object();
	obj.textNames = textNames;
	obj.inputValues = inputValues;
	obj.selectType = selectType;
	if(showTargets==false){
	obj.showTarget = showTargets;
	}else{
	obj.showTarget = "true";
	}
	var value = window.showModalDialog(url,obj,"dialogHeight:500px;dialogWidth:720px;status=off");
	if(value==""||value==undefined) {
	   
	    if(evalscript!=undefined&&evalscript!=""){
	      var script = evalscript+'()';
		  eval(script);
	      return "";
	    }
	    else
	    {
	      return "";
	    }
	}
    if(value=="empty") {
		document.getElementsByName(inputTextName)[0].value = "";
	    document.getElementsByName(hiddenInputValue)[0].value = "";
	    if(evalscript!=undefined&&evalscript!=""){
	      var script = evalscript+'()';
		  eval(script);
	      return "";
	    }
	    else
	    {
	      return "";
	    }
	    
	}
	var valueArray = value.split(";");
	var newText = "";
	for(var i = 0; i < valueArray.length; i++){
		var groupSplit = valueArray[i].split(",");
			if(groupSplit[1] ==undefined) cotinue;
		if(newText==""){
			newText = groupSplit[1];
		}else{
			newText =  newText+","+groupSplit[1];
		}
	}
	document.getElementsByName(inputTextName)[0].value = newText;
	document.getElementsByName(hiddenInputValue)[0].value = value;
	
	//alert("evalscript::"+evalscript);
	if(evalscript!=undefined&&evalscript!=""){
	    var script = evalscript+'()';
		eval(script);
	}
}

function showAssessGroup(inputTextName,hiddenInputValue,selectType,showTargets){
	var url = context+"/assess/address/assess_group_select_main.jsp";
	var textNames = document.getElementsByName(inputTextName)[0].value;
	var inputValues = document.getElementsByName(hiddenInputValue)[0].value;
	var obj = new Object();
	obj.textNames = textNames;
	obj.inputValues = inputValues;
	obj.selectType = selectType;
	if(showTargets==false){
	obj.showTarget = showTargets;
	}else{
	obj.showTarget = "true";
	}
	var value = window.showModalDialog(url,obj,"dialogHeight:500px;dialogWidth:720px;status=off");
	if(value==""||value==undefined) {
	    return "";
	}
    if(value=="empty") {
		document.getElementsByName(inputTextName)[0].value = "";
	    document.getElementsByName(hiddenInputValue)[0].value = "";
	    return "";
	}
	var valueArray = value.split(";");
	var newText = "";
	for(var i = 0; i < valueArray.length; i++){
		var groupSplit = valueArray[i].split(",");
			if(groupSplit[1] ==undefined) cotinue;
		if(newText==""){
			newText = groupSplit[1];
		}else{
			newText =  newText+","+groupSplit[1];
		}
	}
	document.getElementsByName(inputTextName)[0].value = newText;
	document.getElementsByName(hiddenInputValue)[0].value = value;
}

